Release 10.1A: OpenEdge Development:
ProDataSets


SAVE-ROW-CHANGES method

Note: Some of the behavior and attributes described in this and the following section require the first Service Pack for OpenEdge 10, release 10.0A01.

Once a set of changes has been completed, you can use the SAVE-ROW-CHANGES method on a before-table buffer handle to save the changes recorded in that row back to the Data-Source. For example:

Syntax
buffer-handle:SAVE-ROW-CHANGES ( [ buffer-index | buffer-name  
                                 [ , create-field ]] ). 

Where:

This method does the default handling of a create, modify, or delete on that buffer’s record. There is no SAVE-CHANGES method for an entire change ProDataSet or temp-table. Instead, you execute the row-level method for each row you want saved. This way you can determine the exact sequence, transaction scoping, and other coding details for handling a set of related changes. Note that although we speak of a set of related changes and provide methods to handle multiple changes at a time, you can just as easily make a single row change and save it back to the Data-Source.

In a distributed application, you will typically collect just the changes into a change-ProDataSet using GET-CHANGES, and then pass them back to the server to be processed by executing SAVE-ROW-CHANGES on each row. However, there is no need always to use GET-CHANGES to extract just the change rows from the original ProDataSet. This is simply an optimization step to minimize network traffic for a distributed application. If you are not passing changes across a network, you can just as easily execute SAVE-ROW-CHANGES on each before-table row in the origin ProDataSet. How you use the methods is entirely up to you.

Changes can be automatically saved only for a single buffer at a time. If there is more than one buffer in the Data-Source, you can specify which buffer to update as the first argument to SAVE-ROW-CHANGES. Typically, an update to a row that contains fields from multiple database tables updates only one of those tables. For example, in the example we have been using of a ttOrder table that joins in the Customer Name from the Customer table and the SalesRep name from the SalesRep table, your application would not normally allow the user to change the Customer Name by updating one of its Orders. This is because the Name is directly associated with the CustNum field that is the actual join field between the tables, and there would be no proper way to map a change to Customer Name for one Order with either the Customer table or with other Orders for the same Customer.

If you have a special situation where you are, in fact, updating both sides of a join through a ProDataSet (which might be the case if the join is one-to-one) then you can use SAVE-ROW-CHANGES to assign fields from one table and assign the others in your own code, or you can execute SAVE-ROW-CHANGES on each buffer in turn. Otherwise, if your update requirements are quite specialized, you can simply not use the method at all and assign all fields yourself. As with other methods, all the steps taken by SAVE-ROW-CHANGES can be duplicated in your own code when you need to change the default behavior.

You must assure that the Data-Source is attached before doing a SAVE-ROW-CHANGES. In cases where there is no Data-Source or where special processing is needed, you must write the update code yourself instead of using SAVE-ROW-CHANGES.

SAVE-ROW-CHANGES goes through these steps for a modified row:

For a newly created row, SAVE-ROW-CHANGES creates the record in the database and buffer-copies all data table buffer fields except any create-field to the database buffer. It then validates and copies the database record back to the temp-table buffer as for a modified row.

For a deleted row, SAVE-ROW-CHANGES deletes the corresponding row from the Data-Source, based on the record’s keys.

As with a modified row, SAVE-ROW-CHANGES can create or delete only a single database buffer at a time, not both sides of a one-to-one join. In most cases, the creation or deletion of related rows is likely to be implemented in the CREATE or DELETE trigger for the primary buffer anyway.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095